package com.chen.servicedriveruser.service;

import com.chen.internalcommon.dto.ResponseResult;
import com.chen.servicedriveruser.mapper.DriverUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author chenLiuPing
 **/
@Service
@Slf4j
public class CityDriverUserService {

    @Autowired
    private DriverUserMapper driverUserMapper;

    /**
     * 查询指定城市是否有司机
     * @param cityCode 城市编码
     * @return
     */
    public ResponseResult isAvailableDriver(String cityCode) {
        log.info("isAvailableDriver start");
        int count = driverUserMapper.selectDriverUserCountByCityCode(cityCode);
        if (count > 0) {
            log.info("城市：{} 有可用司机", cityCode);
            return ResponseResult.success(true);
        }
        log.info("城市：{} 没有可用司机", cityCode);
        return ResponseResult.success(false);
    }
}
